'use strict';

/*let ab = 'test';
console.log(a);
var [a,b,c] = [1,2,3];
console.log(a,b,c);
var items = new Set([1,2,3,3,3,3,2,34,5]);
console.log(items.size);


[1,2,3,3,3,3,2,34,5].foreach(function(x){

})

const s = new Set();
[1,2,3,3,3,3,2,34,5].forEach(x => s.add(x));

for (let i of s){
    console.log(i)
}

var seta = new Set([1,2,3,4,5,6]);
console.log(seta)

let set = new Set();
set.add(1).add(2).add(3);
console.log(set.size);
set.delete(2);
console.log(set);
console.log(set.size);*/

/*const s = new Set();
[1,2,3,3,3,3,2,34,5].forEach(x => s.add(x));

console.log(Array.from(s));


/*function dedupe(arr){
    return Array.from(new Set(arr));
}
var dedupe = arr => Array.from(new Set(arr));
console.log(dedupe([1,1,1,2,3,5,6]));

let ws = new WeakSet();
var obj = {};
var foo = {};
ws.add(obj);
ws.add(window);

console.log(ws.has(obj),ws.has(window))

ws.delete(window);
console.log(ws.has(obj),ws.has(window))

let map = new Map([
  [1, 'one'],
  [2, 'two'],
  [3, 'three'],
]);

console.log([...map.entries()])

let map0 = new Map().set(1,'a').set(2,'b').set(3,'c');

let map1 = new Map(
    [...map0].filter( ([k,v]) => k<3 )
);

let map2 = new Map(
    [...map0].map( ([k,v]) => [k*2,'%'+v] )
);
console.log(map2.entries())

function add(...x){
    console.log(x.reduce((m,n) => m+n));
}

add(1,3,33)
let i= 0;
for(;i<10;i++){
    setTimeout(function(){
        console.log(i);
    })
}

var obj = {
    'a':1,
    'b':2
}

var intercptor = {
    set:function(receiver, property, value){
        console.log(property,'is changed to',value);
        receiver[property] = value;
    }
}
obj = new Proxy(obj,intercptor);
obj.a = 3;

let a =2; console.log(a**5)

function foo({x,y=5}){
    console.log(x,y);
}
foo({});
foo({x:2});
foo();
console.log( (function({x,y,d,e=1}){}).length);

let insert = (value) => ({into: (array) => ({after: (afterValue) => {
    array.splice(array.indexOf(afterValue) + 1, 0, value);
    return array;
}})});

let insert = (value) => ({into: (array) => ({after: (aftervalue) => {
    array.splice.(array.indexOf(aftervalue) + 1, 0, value);
    return array;
}})})
function factorial(n, total) {
  if (n === 1) return total;
  return factorial(n - 1, n * total);
}
factorial(5,1);

function f() {
  let m = 1;
  let n = 2;
  return g(m + n);
}
f();

let s = Symbol();

console.log(typeof s);



var promise = new Promise(function(resolve,reject){
  if(){
    resolve(value)
  }else{
    reject(error)
  }
})

promise.then(function(value){},function(error){})

let promise = new Promise(function(resolve, reject){
  console.log('Promise');
  resolve();
});

promise.then(function(){
  console.log('Resolved');
})
console.log('hi');

var p1 = new Promise(function(resolve,reject){
  //setTimeout(function(){},3000);

  setTimeout(() => {reject('fail')}, 3000)
})

var p2 = new Promise(function(resolve, reject){
  setTimeout( () => {resolve(p1)}, 1000)
})

/*p2.then(
  function(result){ console.log(reslut)},
  function(error){ console.log(error);}
)

p2.then(
  result => console.log(reslut),
  error => console.log(error)
);

p2.then(
  (result) => {console.log(reslut)},
  (error) => {console.log(error);}
)

function* demo() {
 // console.log('Hello' + yield); // SyntaxError
 // console.log('Hello' + yield 123); // SyntaxError

  console.log('Hello' + (yield)); // OK
  console.log('Hello' + (yield 123)); // OK
}
demo.next();

function Point(x,y){
  this.x = x;
  this.y = y;
}

Point.prototype.toString = function(){
  return '('+ this.x +','+ this.y +')';
}

var p = new Point(3,3);
alert(p.toString())

class Point{
  constructor(x,y){
    this.x = x;
    this.y = y;
  }

  toString(){
    return '('+this.x +','+this.y+')';
  }
}

var p = new Point('a',3);
alert(p.toString())
*/

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

var methodName = 'getArea';

var Square = function () {
  function Square(length) {
    _classCallCheck(this, Square);
  }

  _createClass(Square, [{
    key: methodName,
    value: function value() {
      alert('test');
    }
  }]);

  return Square;
}();

var aa = new Square();
aa.getArea();
